package net.zjitc.controller;

import net.zjitc.pojo.Product;
import net.zjitc.service.ProduceService;
import net.zjitc.service.impl.ProductServiceImpl;
import net.zjitc.utils.PageBean;
import net.zjitc.utils.dispacher.URLMapping;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Created by Administrator on 2017/11/22.
 */
public class AdminProduct{
    ProduceService produceService = new ProductServiceImpl();
    //显示列表
    @URLMapping(url = "/AdminProductFindALL")
    public String findAll(HttpServletRequest request, HttpServletResponse response){
        int page = 1;
        int pageSize = 12;
        PageBean<Product> pageBean = produceService.findPageBean(page,pageSize);
        request.setAttribute("page",pageBean);
        return "/admin/product/list.jsp" ;
    }

    //显示添加页面
    @URLMapping(url = "/AdminProductAddUI")
    public String addUI(HttpServletRequest request, HttpServletResponse response){

        return "/admin/product/add.jsp" ;
    }

    //添加功能
    @URLMapping(url = "/AdminProductAdd")
    public String add(HttpServletRequest request, HttpServletResponse response){

        //添加完后，要重定向到。。。。。
        String url = request.getContextPath()+"/AdminProductFindALL";
        return "Redirect:"+url ;
    }

    //显示修改页面
    @URLMapping(url = "/AdminProductEditUI")
    public String editUI(HttpServletRequest request, HttpServletResponse response){

        return "/admin/product/edit.jsp" ;
    }


    //更新功能
    @URLMapping(url = "/AdminProductEdit")
    public String edit(HttpServletRequest request, HttpServletResponse response){

        //更新完后，要重定向到。。。。。
        String url = request.getContextPath()+"/AdminProductFindALL";
        return "Redirect:"+url ;
    }

    //删除功能
    @URLMapping(url = "/AdminProductDelete")
    public String delete(HttpServletRequest request, HttpServletResponse response){

        //删除完后，要重定向到。。。。。
        String url = request.getContextPath()+"/AdminProductFindALL";
        return "Redirect:"+url ;
    }
}
